<!DOCTYPE html>
<html lang="en">
<head>
	<title>CSS3测试</title>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<meta name="format-detection" content="address=no">
	<meta name="format-detection" content="email=no">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<style>
	</style>
</head>
<body>
	<div id="div3" style="background:green">我是div3</div>
	<div id="div1" style="background:pink">我是div1</div>
	<div id="div2" style="background:#f3334a">我是div2</div>
</body>

<script>
	$(function() {
	    var page = 0; //
	    //滚动加载
	    $(document).on('click', _click = function() {
	        var flag = 0; //是否加载到最后一页
            //满足滚动条件
            page++;
            scrollAjax(page,flag);
	    });
	    //滚动请求Ajax
	    function scrollAjax(page,flag){
	        // page++;
	        var url = 'http://m.duobaodaka.com/h5/invite/get_my_friend_list';
	        $.ajax({
	            type: 'get',
	            url:  url + '?page=' + page,
	            dataType: 'json',
	            timeout: 6000,
	            beforeSend: function() {
	                // 禁用按钮防止重复提交
	                $(document).off('click', _click);
	            },
	            success: function(data) {
	                console.log(data);
	                //数据传递验证成功后执行的操作
	                if (data.code == 200) {
	                   
	                } else if (data.code != 200) {
	                    flag = 1;
	                    $('.friend_list').append('<div class="tips text-center text-muted">没有更多数据了</div>');

	                }
	            },
	            complete: function() {
	                if (flag == 1) {
	                    $(document).off('click', _click);
	                } else {
	                    $(document).on('click', _click);
	                }
	            },
	            error: function(jqXHR, textStatus, errrorThrown) {
	                if (errrorThrown == 'Not Found') {
	                    console.log('Your requested address is not found.');
	                } else if (textStatus == 'timeout') {
	                    console.log('Verify the request timeout, please refresh the page and try again');
	                } else {
	                    console.log('Your requested address is not found.');
	                }
	            }
	        });
	    }
	});
</script>
</html>